/**
 * 精度失真处理
 * @param str
 * @returns {*}
 */
export const resetLongToStr = (str)=>{
  return  str.replace(/:s*([0-9]{15,})s*(,?)/g, ': "$1" $2');
}

/**
 * @description: 判断值是否为某个类型
 * @param {unknown} val - 要检查的值
 * @param {string} type - 目标类型的字符串表示，例如 "Object"、"Function" 等
 * @returns {boolean} 如果值是指定类型，则返回 true，否则返回 false
 */
export const objectIsEq = (val, type) =>{
  return Object.prototype.toString.call(val) === `[object ${type}]`;
}
/**
 * 数组映射
 * @param mapperArr
 * @param oldArray
 * @returns {*[]}
 */
export const arrProcessingData = (mapperArr = [],oldArray=[])=> {
  let newArray = [];
  // 遍历旧数组
  for (let item of oldArray) {
    let newObject = {...item};
    // 遍历 beanData，根据映射规则生成新对象
    for (let mapping of mapperArr) {
      const { beanName, sourceName } = mapping;
      if (sourceName && sourceName!=='' && item.hasOwnProperty(sourceName)){
        newObject[beanName] = item[sourceName]
      }
    }
    // 将生成的对象添加到新数组
    newArray.push(newObject);
  }
  return newArray;
}
